package my.test.responsibilitychain;

import java.util.ArrayList;
import java.util.Random;

public class Client {

    public static void main(String[] args) {
        Random random = new Random();
        ArrayList<IWomen> arrayList = new ArrayList<>();
        for (int i = 0; i < 5; i++) {
            arrayList.add(new Women(random.nextInt(4), "我要去逛街"));
        }

        //定义三个请示对象
        IHandler father = new Father();
        IHandler huaband = new Husband();
        IHandler son = new Son();

        for(IWomen women : arrayList) {
            if("1".equals(String.valueOf(women.getType()))) {
                System.out.println("\n-----女儿像父亲请示------");
                father.HandlerMessage(women);
            } else if("2".equals(String.valueOf(women.getType()))) {
                System.out.println("\n-----妻子向丈夫请示------");
                huaband.HandlerMessage(women);
            } else if("3".equals(String.valueOf(women.getType()))) {
                System.out.println("\n-----母亲向儿子请示------");
                son.HandlerMessage(women);
            } else {
                //暂时什么也不做
            }
        }

    }
}
